package com.example.su_shi_tan_core.utils

import android.content.Context
import android.util.Log
import android.view.View
import android.widget.EditText
import com.example.su_shi_tan_bas_lib.utils.PixUtils
import com.example.su_shi_tan_core.R
import com.example.su_shi_tan_core.constant.SignUserBeanHolder
import com.example.su_shi_tan_core.db.UserInfoBeanHolder
import com.lxj.xpopup.core.CenterPopupView

class PayingPassWordVerifyPop(context: Context) : CenterPopupView(context) {

    private var verifyPop = false

    private var isOnVerifyPop = false

    fun getVerifyPop(): Boolean {
        return verifyPop
    }

    fun getIsOnVerifyPop() = isOnVerifyPop

    override fun getPopupHeight(): Int {
        return PixUtils.dp2px(180)
    }

    override fun getImplLayoutId(): Int {
        return R.layout.paying_pass_word_verify_pop
    }

    override fun onCreate() {
        super.onCreate()
        val passwordEdt: EditText = findViewById(R.id.passwordEdt)

        findViewById<View>(R.id.tv_done).setOnClickListener {
            isOnVerifyPop = true
            identityPassword(passwordEdt.text.toString())
        }
    }

    private fun identityPassword(toString: String) {
        val mD5Str = MD5Util.getMD5Str(toString)

        val payPasswd = SignUserBeanHolder.getSignUser()?.pay_pwd
        verifyPop = mD5Str == payPasswd
        Log.d("identityPassword", "payPasswd: $payPasswd")
        Log.d("identityPassword", "mD5Str: $mD5Str")
        dismiss()
    }


}